﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;

namespace SolutionOrchestrator
{
	class BooleanToVisibility : IValueConverter
	{
		public bool IsNegate { get; set; }

		/// <summary>
		/// true = Hide, false = Collapse
		/// </summary>
		public bool IsHide { get; set; }

		#region Implementation of IValueConverter

		public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
		{
			if (value is bool)
			{
				var b = (bool)value;
				if(IsNegate)
				{
					b = !b;
				}
				return b ? Visibility.Visible : (IsHide ? Visibility.Hidden : Visibility.Collapsed);
			}
			return value;
		}

		public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
		{
			throw new NotSupportedException();
		}

		#endregion
	}
}
